Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fold instead of obliterating args #105611

Merged
merged 2 commits into from
Dec 14, 2022

Conversation

BoxyUwU
Copy link
Member

@BoxyUwU BoxyUwU commented Dec 12, 2022

Fixes #105608

we call const_eval_resolve on the following constant:

def: playground::{impl#0}::and::{constant#0},
substs: [
  ConstKind::Unevaluated {
    def: playground::{impl#0}::and::{constant#0},
    substs: [
      ConstKind::Value(0x0),
      _,
    ]
  }
  _,
],

when expanded out to ConstKind::Expr there are no infer vars so we attempt to evaluate it after replacing infer vars with garbage, however the current logic for replacing with garbage replaces the whole arg containing the infer var rather than just the infer var. This means that after garbage replacement has occured we attempt to evaluate:

def: playground::{impl#0}::and::{constant#0},
substs: [
  PLACEHOLDER,
  PLACEHOLDER,
],

Which then leads to ctfe being unable to evaluate the const. With this PR we attempt to evaluate:

def: playground::{impl#0}::and::{constant#0},
substs: [
  ConstKind::Unevaluated {
    def: playground::{impl#0}::and::{constant#0},
    substs: [
      ConstKind::Value(0x0),
      PLACEHOLDER,
    ]
  }
  PLACEHOLDER,
],

which ctfe can handle.

I am not entirely sure why this function is supposed to replace params with placeholders rather than just inference vars 🤔

@BoxyUwU BoxyUwU added the A-const-generics Area: const generics (parameters and arguments) label Dec 12, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 12, 2022

r? @wesleywiser

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 12, 2022
@wesleywiser
Copy link
Member

Thanks @BoxyUwU!

@bors r+

@bors
Copy link
Contributor

bors commented Dec 13, 2022

📌 Commit 5573485 has been approved by wesleywiser

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 13, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 14, 2022
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#103644 (Add docs for question mark operator for Option)
 - rust-lang#105161 (Refine when invalid prefix case error arises)
 - rust-lang#105491 (Illegal sized bounds: only suggest mutability change if needed)
 - rust-lang#105502 (Suggest impl in the scenario of typo with fn)
 - rust-lang#105523 (Suggest `collect`ing into `Vec<_>`)
 - rust-lang#105595 (Suggest dereferencing receiver arguments properly)
 - rust-lang#105611 (fold instead of obliterating args)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0146969 into rust-lang:master Dec 14, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE: Missing constant with generic_const_exprs
4 participants